package com.ruoyi.wlxz.controller;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.wlxz.util.DataCronUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wlxz.domain.WxzPublishedActivity;
import com.ruoyi.wlxz.service.IWxzPublishedActivityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
 * 活动发布Controller
 * 
 * @author 张浩
 * @date 2025-07-21
 */
@RestController
@RequestMapping("/wlxz/activity")
public class WxzPublishedActivityController extends BaseController
{
    @Autowired
    private IWxzPublishedActivityService wxzPublishedActivityService;
    /**
     * 查询活动发布列表
     */
    @PreAuthorize("@ss.hasPermi('wlxz:activity:list')")
    @GetMapping("/list")
    public TableDataInfo list(WxzPublishedActivity wxzPublishedActivity)
    {
        startPage();
        List<WxzPublishedActivity> list = wxzPublishedActivityService.selectWxzPublishedActivityList(wxzPublishedActivity);
        return getDataTable(list);
    }
    /**
     * 导出活动发布列表
     */
    @PreAuthorize("@ss.hasPermi('wlxz:activity:export')")
    @Log(title = "活动发布", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxzPublishedActivity wxzPublishedActivity)
    {
        List<WxzPublishedActivity> list = wxzPublishedActivityService.selectWxzPublishedActivityList(wxzPublishedActivity);
        ExcelUtil<WxzPublishedActivity> util = new ExcelUtil<WxzPublishedActivity>(WxzPublishedActivity.class);
        util.exportExcel(response, list, "活动发布数据");
    }
    /**
     * 获取活动发布详细信息
     */
    @PreAuthorize("@ss.hasPermi('wlxz:activity:query')")
    @GetMapping(value = "/{activityId}")
    public AjaxResult getInfo(@PathVariable("activityId") Long activityId)
    {
        return success(wxzPublishedActivityService.selectWxzPublishedActivityByActivityId(activityId));
    }
    /**
     * 新增活动发布
     */
    @PreAuthorize("@ss.hasPermi('wlxz:activity:add')")
    @Log(title = "活动发布", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxzPublishedActivity wxzPublishedActivity)
    {
        return toAjax(wxzPublishedActivityService.insertWxzPublishedActivity(wxzPublishedActivity));
    }
    /**
     * 修改活动发布
     */
    @PreAuthorize("@ss.hasPermi('wlxz:activity:edit')")
    @Log(title = "活动发布", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxzPublishedActivity wxzPublishedActivity)
    {
        return toAjax(wxzPublishedActivityService.updateWxzPublishedActivity(wxzPublishedActivity));
    }
    /**
     * 删除活动发布
     */
    @PreAuthorize("@ss.hasPermi('wlxz:activity:remove')")
    @Log(title = "活动发布", businessType = BusinessType.DELETE)
	@DeleteMapping("/{activityIds}")
    public AjaxResult remove(@PathVariable Long[] activityIds)
    {
        return toAjax(wxzPublishedActivityService.deleteWxzPublishedActivityByActivityIds(activityIds));
    }
}
